
CC = g++
CFLAGS = -I$(inFloder)/ -lm -lpthread -O3 -march=native -Wall -Wno-comment -finput-charset=GBK -mavx -std=gnu++11

inFloder = src

cbals=/usr/local/openbals-0.3.0

PREFIX = /usr/local/hanzhi-0.01

soFloder = $(PREFIX)/lib
includeFloder = $(PREFIX)/include

coreFiles = $(inFloder)/core/HanZhi_en.cpp $(inFloder)/core/CPU_en.cpp  \
$(inFloder)/core/CPUCalculator_en.cpp

w2vFiles = $(inFloder)/w2v/w2v_en.cpp

nnFiles = $(inFloder)/nn/actuator_en.cpp $(inFloder)/nn/cal_en.cpp $(inFloder)/nn/CPUCalMaxPool_en.cpp \
$(inFloder)/nn/data_en.cpp $(inFloder)/nn/graph_en.cpp $(inFloder)/nn/nodes_en.cpp $(inFloder)/nn/train_en.cpp

	
hanzhi:libhanzhiCore.so libw2v.so libnn.so 
	
libhanzhiCore.so:$(coreFiles)
	$(CC)  $(coreFiles) -fPIC -shared -o libhanzhiCore.so $(CFLAGS)
	
libw2v.so:$(w2vFiles)
	$(CC)  $(w2vFiles) -fPIC -shared -o libw2v.so $(CFLAGS)
	
libnn.so:$(nnFiles)
	#如果要使用CBLAS需要先安装CBLAS，然后使用【-D USE_CBLAS】进行编译
ifeq ($(USE_CBLAS), y)
	$(CC)  $(nnFiles) -fPIC -shared -o libnn.so $(CFLAGS) -I$(cbals)/include -D USE_CBLAS
else
	$(CC)  $(nnFiles) -fPIC -shared -o libnn.so $(CFLAGS)
endif
	
install:
	install -d $(soFloder)
	install -m 755 libhanzhiCore.so $(soFloder)/libhanzhiCore.so
	install -m 755 libw2v.so $(soFloder)/libw2v.so
	install -m 755 libnn.so $(soFloder)/libnn.so
	echo $(soFloder) > hanzhi-x86_64.conf	
	install -m 644 hanzhi-x86_64.conf /etc/ld.so.conf.d/hanzhi-x86_64.conf	
	rm hanzhi-x86_64.conf -f
	install -d $(includeFloder) $(includeFloder)/core $(includeFloder)/w2v $(includeFloder)/nn
	install -m 755 $(inFloder)/core/*.h $(includeFloder)/core
	install -m 755 $(inFloder)/w2v/*.h $(includeFloder)/w2v
	install -m 755 $(inFloder)/nn/*.h $(includeFloder)/nn
	install -m 755 $(inFloder)/nn/*.type $(includeFloder)/nn
	ldconfig
	
uninstall:
	rm /etc/ld.so.conf.d/hanzhi-x86_64.conf $(soFloder) $(includeFloder) -rf
	ldconfig
	
clean:
	rm libhanzhiCore.so libw2v.so libnn.so -f

	
	
	
	